<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        function setCookie(name, value, options) {
            options = options || {};
            if (typeof options.expires === "number") {
                let date = new Date();
                date = date.getDate() + options.expires;
            }
            return document.cookie = [
                name + "=" + value,
                typeof options.path === "string" ? ";path=" + options.path : "",
                typeof options.expires === "number" ? ";expires=" + options.expires : "",
                typeof options.domain === "string" ? ";domain=" + options.domain : ""
            ].join("");
        }

        setCookie("qwer", "asdasd", {
            domain: "localhost"
        })
    </script>
</body>

</html>